<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>授权 {{$_REQUEST['client_id']}} 访问135帐号 - {{$site[title]}}</title>
    <?php
        echo $this->Html->css(array(
            'reset',
			'bootstrap.min.css',
        ));
echo $this->Html->script(array(
        	'jquery/jquery.min.js',
        ));
        echo $scripts_for_layout;
    ?>
<style type="text/css">
* { word-break: break-all; }
body {margin:0; background:#f4f6f8; padding:0;font-size:12px;line-height: 1.8; }
#login-content {
	padding:10px 0px 30px;
	max-width: 360px;
    margin: 0 auto;
}
#login{
	background:#FFF; 
	margin:0 auto;padding: 50px 15px;
	width:auto;max-width: 688px;
	border: 1px solid #DDD;
	border-radius: 0 0 10px 10px;
	box-shadow: 0 0 6px rgba(0,0,0,.10);
}
h1,h2 { 
	font-size:18px; margin:1px 0 0; line-height:50px; height:50px; 
	color:#FFF; padding-left:30px; 
	text-align: left;font-weight:bold;
}
.sitename {
	font-size:18px; margin:1px 0 0; line-height:50px; height:50px; 
	color:#FFF;
	text-align: left;font-weight:bold;
}
.form-horizontal .control-label{
	display:inline-block;float:left;
	text-align:left;
}
a:hover, a:focus{text-decoration: none;color:#FFF;}
</style>
<script type="text/javascript">

function ajaxLogin(form){
	var url = form.action;
	var postdata = $(form).serialize();
	if(url.search(/\?/)!=-1){
		url+='&inajax=1';
	}
	else{
		url+='?inajax=1';
	}
	if(form){
		$(':submit',form).each(function(){
			var html = $(this).html();
			$(this).data('html',html).html('<img src="'+'/img/ajax/circle_ball.gif"> '+html).attr('disabled','disabled'); // 将按钮置为不可提交
		});
	}
	$.ajax({
		// async:true,
		type:'post',
		url: url,
		data: postdata,
		complete:function (XMLHttpRequest, textStatus) {
			if(form){
				$(':submit',form).each(function(){
					var html = $(this).data('html');
					$(this).html(html).removeAttr('disabled');
				}) // 将按钮置为可提交
			}
		},
		success: function(request){
			if(request.success) {
				$('#loged-authorize-form').submit();
			}
		},
		dataType:"json"
	});
	return false;
}

</script>
</head>

<div style="height: 48px;background:#2c3e50;">
    <div style="margin:0 auto;max-width: 688px;">
    	<a href="/" class="sitename"  title="135编辑器"><img src="http://image.135editor.com/files/201412/4d10fae23551a6be4a8ef6d3.png" style="height:48px;max-width:90px;padding:10px">135编辑器</a>
    </div>
</div>

<div id="login">
	<div  id="login-content">
		{{if $current_user_id}}
		<p>{{$CurrentUser['username']}}，你好</p>
		{{/if}}
		<p>授权 <strong>{{$_REQUEST['client_id']}}</strong> 访问你的135帐号 </p>
		<p>{{$_REQUEST['client_id']}}不会知道您的账号密码，授权后可与135账号绑定关系。</p>
		{{if !$current_user_id}}
	       <form class="reg-page"  action="{{$this->Html->url('/users/login')}}" id="loginform" accept-charset="utf-8"  method="post" role="form" onsubmit="return ajaxLogin(this);">
                <div class="form-group help-block" id="login_errorinfo"></div>    
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                            <i class="fa fa-envelope"></i>
                            {{__('Email')}}
                        </span>

                        <input type="hidden" name="data[User][referer]" value="{{$this->data['User']['referer']}}">
                        <input type="email" required="required" name="data[User][email]" id="UserEmail" class="form-control" placeholder="{{__('Email')}}">
                    </div>
                </div>
                <div class="form-group">                  
                    <div class="input-group">
                        <span class="input-group-addon">
                            <i class="fa fa-lock"></i>
                            {{__('Password')}}
                        </span>
                        <input type="password"  required="required" maxlength="15"  name="data[User][password]" class="form-control" placeholder="{{__('Password')}}">
                    </div>
                </div>
                
                <div class="form-group">
                    <div class="clearfix">
                            <button type="submit"  class="btn-primary btn btn-default">{{__('Login')}}</button>  
                    </div>
                </div>
          </form> 
          {{/if}}
          <form method="post" {{if !$current_user_id}} style="display:none;" {{/if}} id="loged-authorize-form">
			  <input type="hidden"  name="authorized" value="yes">
			  <input type="submit"  class="btn-primary btn btn-default" value="确认授权">
			</form>
	</div>
	<p style="text-align:center;">提示：为保障帐号安全，请认准本页URL地址必须以 www.135editor.com 开头</p>
	
</div>
	</body>
</html>